home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-06-03 | 2.7 KB | 90 lines | [TEXT/IGR0] |
- #include <Execute Cmd On List>
- Menu "Load Waves"
- "-"
- "Load All Waves In Folder..."
- End
-
- Menu "Data"
- "-"
- "Copy All Waves To Home..."
- End
-
- | LoadAllWavesInFolder - Loads all Igor Binary files or all Text files in a folder as waves.
- Proc LoadAllWavesInFolder(type,naming,precision,base,overwrite,makeTable,copyToHome,otherFlags)
- Variable type,naming,overwrite,precision,makeTable,copyToHome,
- String base="wave",otherFlags
- Prompt type,"data in file:",popup,"Igor Binary;Igor Text;General Text;Delimited Text;"
- Prompt naming,"assign text file wave names:",popup,"auto names using base name;from file, no name dialog;from file, name dialog;"
- Prompt precision,"precision of loaded text:",popup,"double [64 bits];single [32 bits];"
- Prompt base,"auto names start with:"
- Prompt overwrite,"overwrite existing waves?:",popup,"Yes;No;"
- Prompt makeTable,"table options:",popup,"_none_;create new table for waves;append waves to top table;"
- Prompt copyToHome,"copy Igor Binary wave(s) to home?:",popup,"yes: files not needed anymore;no: files are part of experiment"
- Prompt otherFlags,"enter any other LoadWave flags:"
-
- Silent 1;PauseUpdate
- Variable jg=0
- String fileType="TEXT"
- String cmd= "LoadWave"
- if( makeTable > 1 )
- cmd+="/E=2" | always append, so multiple file loads are on same table.
- endif
- if( copyToHome==1 )
- cmd+="/H"
- endif
- if( overwrite==1 )
- cmd+="/O"
- endif
- if( type == 1 )
- fileType="IGBW" | Igor Binary
- else
- if( type == 2 )
- cmd+="/T" | Igor Text
- else
- if( type == 3 )
- cmd+="/G"; jg=1 | General Text
- else
- if( type == 4 )
- cmd+="/J"; jg=1 | Delimited Text
- endif
- endif
- endif
- endif
- if( jg ) | some options apply only to /J or /G
- if( naming == 1 ) | auto base
- cmd+="/A"
- if( strlen(base) > 0 )
- cmd+= "="+base
- endif
- else | from file
- cmd+="/W"
- if( naming == 2 )
- cmd+="/A" | trust file contents, no dialog
- endif
- endif
- if( precision == 1 ) | double
- cmd+="/D"
- endif
- endif
- cmd+= otherFlags + "/P=dataFolder \"%s\""
- NewPath/O/M="select folder of Igor Binary waves" dataFolder | dialog
- String files= IndexedFile(dataFolder,-1,fileType) | list of all files
- if( makeTable == 2 )
- Edit | blank table to append to
- endif
- ExecuteCmdOnList(cmd, files)
- End
-
- | The CopyAllWavesToHome macro copies all waves in the experiment to home,
- | which adopts all shared waves so that references to external files are no longer
- | needed (see Sharing Versus Copying Igor Binary Files):
- Proc CopyAllWavesToHome()
- PathInfo home
- if( V_Flag == 0 )
- Abort "Home path not defined. You must save the experiment to define it."
- endif
- DoAlert 1,"This operation is not undoable.\r\rReally copy all shared waves into this experiment?"
- if( V_Flag == 1)
- ExecuteCmdOnList("Save/P=home/O %s", WaveList("*",";",""))
- endif
- End